import axios from 'axios'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// 默认地址
export const baseURL = process.env.NODE_ENV === 'production' ? 'http://localhost:3001' : 'http://localhost:3001'

const request = axios.create({ baseURL })

// 请求拦截器
request.interceptors.request.use(config => {
  NProgress.start()
  return config
})

// 响应拦截器
request.interceptors.response.use(config => {
  NProgress.done()
  return config
})

export default request
